package com.ruoyi.web.controller.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.domain.WOrderDeliver;
import com.ruoyi.system.domain.vo.WOrderDeliverVO;
import com.ruoyi.system.service.IWOrderDeliverService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 物料订单发货Controller
 * 
 * @author ruoyi
 * @date 2021-12-05
 */
@RestController
@Api(value = "客户物料订单发货",tags = "物料订单")
@RequestMapping("/system/orderdeliver")
public class WOrderDeliverController extends BaseController
{
    @Autowired
    private IWOrderDeliverService wOrderDeliverService;

   //处理订单 处理粗存 处理发货表数据
    @ApiOperation("工厂发货接口")
    @PostMapping("addDeliver")
    public R<WOrderDeliver> addDeliver(@RequestBody WOrderDeliver wOrderDeliver)
    { 
    	LoginUser loginUser = getLoginUser();
    	wOrderDeliver.setCreateBy(loginUser.getUsername());
    	return wOrderDeliverService.addDeliver(wOrderDeliver);
    }
    
    @ApiOperation("小程序查询发货列表")
    @GetMapping("wOrderDeliverListSmall")
    public R<List<WOrderDeliverVO>> wOrderDeliverListSmall(WOrderDeliverVO wOrderDeliver )
    { 
    	LoginUser loginUser = getLoginUser();
    	Long deptId = loginUser.getDeptId();
    	wOrderDeliver.setDeptId(deptId);
    	
    	return R.success( wOrderDeliverService.selectWOrderDeliverList(wOrderDeliver));
    }
    @ApiOperation("小程序 查询发货i详情")
    @PostMapping("selectWOrderDeliverInfo/{id}")
    public R<WOrderDeliverVO> selectWOrderDeliverInfo(@PathVariable("id") Long id)
    { 
    	WOrderDeliverVO wOrderDeliver = new WOrderDeliverVO();
    	wOrderDeliver.setId(id);
    	WOrderDeliverVO selectWOrderDeliverInfo = wOrderDeliverService.selectWOrderDeliverInfo(wOrderDeliver);
		return R.success( selectWOrderDeliverInfo);
    }
    
    
    
    @ApiOperation("订单的发货列表接口---交付列表")
    @PostMapping("wOrderDeliverList/{orderId}")
    public R<List<WOrderDeliverVO>> wOrderDeliverList(@PathVariable("orderId") Long orderId)
    { 
    	WOrderDeliverVO wOrderDeliver = new WOrderDeliverVO();
    	wOrderDeliver.setOrderId(orderId);
    	return R.success( wOrderDeliverService.selectWOrderDeliverList(wOrderDeliver));
    }
    
}
